package net.qktianxia.component.logger.demo;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import net.qktianxia.component.logger.IFormatStrategy;
import net.qktianxia.component.logger.ILogStrategy;
import net.qktianxia.component.logger.proveder.Logger;
import net.qktianxia.component.logger.orhanobut.logcat.AndroidLogProxy;
import net.qktianxia.component.logger.orhanobut.logcat.LogcatLogStrategy;
import net.qktianxia.component.logger.orhanobut.format.PrettyFormatStrategy;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        Logger logger=Logger.newBuilder().build();
        //没设置adapter打印代理打印不出来的

        logger.e("第一条打印测试数据%s","===1==");

        //设置android的打印代理
        logger.addLogAdapter(new AndroidLogProxy());
        logger.e("第二条打印测试数据%s","===2==");

        //设置android打印代理的FormatStrategy策略配置
        IFormatStrategy formatStrategy= PrettyFormatStrategy.newBuilder()
                .methodCount(2).methodOffset(3).logStrategy(new ILogStrategy() {
                    @Override
                    public void log(int priority, @Nullable String tag, @NonNull String message) {
                        new LogcatLogStrategy().log(priority,tag,message);
                    }
                }).build();

        logger.addLogAdapter(new AndroidLogProxy(formatStrategy));

        logger.e("第三条打印测试数据%s","=====");

        //清空打印代理
        logger.clearLogProxyList();

        //使用自己的FormatStrategy策略
        logger.addLogAdapter(new AndroidLogProxy(new MyFormatStrategy()));

        logger.e("清除所有打印代理，使用自己的FormatStrategy策略");
        logger.e("第四条打印测试数据：%s","用自己的格式打印出来");

        logger.t("我的TAG").e("自己的TAG打印测试数据：%s","用自己的格式打印出来");




    }
}
